Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create furness_balancing.R #36

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Create furness_balancing.R #36

wants to merge 2 commits into from

Conversation

mem48
Copy link
Collaborator

@mem48 mem48 commented Aug 13, 2024

New functions for Furness balancing matrixes

  • furness_balance simple case of a matrix with known row and column sums
  • furness_partial a version that can take a partially filled matrix and infill the rest
  • matrix_fill_incomplete is a function that can infill a partial matrix when some row and column totals are unknown but a total of the whole matrix is known.

Note that all of these functions find "a" solution, but not always "the" solution. Sometimes no valid solution exists.

Copy link
Owner

@Robinlovelace Robinlovelace left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Many thanks @mem48 and quick work 👍 I will take a look and either push tweaks directly to this branch or put in a PR to your PR for anything I want your feedback on. As per my comment on the examples, I think users need a more tangible example based on a minimal real (or at least realistic) example dataset.

#' @return A vector of rounded numeric
#' @export
#' @example
#' mat = matrix(rep(1, 6), nrow = 3)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great to see an example in the package's style. Clearly works but I think we should have an example that uses real example data. Could example datasets in this package work, or do we need to create more packaged data, e.g. starting with NTEM? Having done some reading it seems to me that Furness balancing is more about updating SIM estimates over time, which would be v. handy and links nicely with the spanishoddata package.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't know about over time, all of these functions are for filling in matrices where you know row/column totals but not internal values. So classic example is knowing the number of pupils at schools and the number of children in each LSOA, but you don't have OD data. You can prime the matrix with values from a distance decay curve and then run the furness balance and you should get a reasonable OD matrix.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't the function assume OD data in matrix form, with rows representing origins and columns representing destinations?

Fine if so, although will not work on large sparse OD datasets, e.g. all schools to all LSOAs which would be 10 * 30 = 300,000,000 cells.

Copy link
Collaborator Author

@mem48 mem48 Sep 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes all these functions are matrix based

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, need to chat this over. Next time both in office could be good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants